/***************************************************************************
 *	@file 		fetion_verify_code.h
 *	@Author 	baoyu0125@gmail.com
 *	@create		2011-7
 *	@version 	1.0.0
 *	@brief		definition of class VerifyCode, VerifyCode is about verification
 *				code
 *	@modify		none
 ***************************************************************************/

#ifndef FETION_VERIFY_CODE_H
#define FETION_VERIFY_CODE_H

using boost::asio::ip::tcp;

typedef struct {
	std::string  algorithm;
	std::string  type;
	std::string  text;
	std::string  tips;
	std::string  code;
	std::string  guid;
} Verification;

class VerifyCode
{
public:
	friend class loginThreadCallable;
	
	VerifyCode(const std::string path, const std::string rs, const std::string tp) 
		: reason(rs), pic_path(path), tip(tp), error(0) {}
	int generate_pic_code();

private:
	int get_pic_code_xml(Glib::ustring &xml);
	int parse_pic_code_xml(const Glib::ustring &xml);
	unsigned char* decode_base64(const char *in, int *len);

	std::string reason;
	std::string pic_path;
	std::string tip;
	int error;
};

#endif
